package com.navidove.appspotlight.model.bo;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "sys_image")
public class SysImage implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private String fileName;
	private String mime;
	private Integer fileSize;
	private byte[] content;
	private Boolean enable;
	private Date crtAt;
	private Date updAt;

	@Id
	@SequenceGenerator(name = "generator", sequenceName = "sys_image_id_seq", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "file_name", nullable = false, length = 100)
	public String getFileName() {
		return this.fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	@Column(name = "mime", nullable = false, length = 100)
	public String getMime() {
		return this.mime;
	}

	public void setMime(String mime) {
		this.mime = mime;
	}

	@Column(name = "file_size", nullable = false)
	public Integer getFileSize() {
		return this.fileSize;
	}

	public void setFileSize(Integer fileSize) {
		this.fileSize = fileSize;
	}

	@Column(name = "content", nullable = false)
	public byte[] getContent() {
		return this.content;
	}

	public void setContent(byte[] content) {
		this.content = content;
	}

	@Column(name = "enable")
	public Boolean getEnable() {
		return this.enable;
	}

	public void setEnable(Boolean enable) {
		this.enable = enable;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "crt_at", length = 29)
	public Date getCrtAt() {
		return this.crtAt;
	}

	public void setCrtAt(Date crtAt) {
		this.crtAt = crtAt;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "upd_at", length = 29)
	public Date getUpdAt() {
		return this.updAt;
	}

	public void setUpdAt(Date updAt) {
		this.updAt = updAt;
	}

	/**
	 * @see java.lang.Object#toString
	 * @return String
	 */
	public String toString() {
		return new ToStringBuilder(this).append("id", getId()).toString();

	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}
		SysImage rhs = (SysImage) obj;

		return new EqualsBuilder().append(getId(), rhs.getId()).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(getId()).toHashCode();
	}

}
